package by.gravity.grsu.shedule.fragments;

import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ListView;
import by.gravity.grsu.shedule.R;
import by.gravity.grsu.shedule.adapter.DayAdapter;
import by.gravity.grsu.shedule.model.Day;

public class DayFragment extends Fragment {

	private static final String DAY_ARG = "day_arg";

	private ListView mLessonList;

	public static DayFragment newInstance(Day day) {
		Bundle bundle = new Bundle();
		bundle.putSerializable(DAY_ARG, day);
		DayFragment fragment = new DayFragment();
		fragment.setArguments(bundle);

		return fragment;

	}

	private DayFragment() {

	}

	@Override
	public void onActivityCreated(Bundle savedInstanceState) {
		super.onActivityCreated(savedInstanceState);
		mLessonList = (ListView) getView().findViewById(R.id.listView);
		DayAdapter adapter = new DayAdapter(getActivity(), R.layout.lesson, getDay().getLessons());
		mLessonList.setAdapter(adapter);

	}

	private Day getDay() {
		return (Day) getArguments().getSerializable(DAY_ARG);
	}

	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
		return inflater.inflate(R.layout.list, null);
	}

}
